<!DOCTYPE html>
<html lang="zh_CN">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
    />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="mobile-web-app-capable" content="yes" />

    <script src="/public/vendor/vue@2.7.14.js"></script>
    <link rel="stylesheet" type="text/css" href="/public/stylesheets/index.css" />
    <script src="/public/vendor/element/index.js"></script>
    <script src="/public/vendor/axios.js"></script>
    <script>
      localStorage.removeItem('search_params');
      localStorage.setItem('search_params', new URLSearchParams(location.search).toString());
    </script>

    <title>Document</title>
  </head>

  <body>
    <script>
      // let headerList = '<%# JSON.stringify(parms) %>';
      // window.headerList = JSON.parse(headerList);
      // const urlParams = new URLSearchParams(location.search);
      // console.log('url', urlParams.toString());
    </script>

    <div id="app" class="app"></div>

    <script type="module">
      new Vue({
        el: '#app',
        mounted: function () {
          // console.log('mounted', window.headerList);
          // this.tableData = window.headerList;
          this.$loading({
            lock: true,
            text: '加载中',
            spinner: 'el-icon-loading',
            background: '#fff',
          });
          const urlParams = new URLSearchParams(location.search);
          const token = urlParams?.get('access_token');
          const formVerId = urlParams?.get('form_ver_id') || '';
          const params = { form_ver_id: formVerId, browse_type: '1' };
          const headers = { Authorization: 'Bearer ' + token };

          axios
            .get('/api/Tim/GetWorkFormVerFile', { params, headers })
            .then((res) => {
              const resData = res.data;
              if (!resData.success) {
                this.$message.error(res.msg || '未知错误');
                return;
              }
              if (resData.data && resData.data.length > 0) {
                urlParams.set('header_id', '');
                urlParams.set('header_file', resData.data);
                window.location.href = `/editor?${urlParams.toString()}`;
                return;
              }
              window.location.href = `/center?${urlParams.toString()}`;
              return;
            })
            .catch((err) => {
              this.$message.error(err.message || '未知错误');
            });
        },
        methods: {},
        data: function () {
          return {
            fullscreenLoading: true,
          };
        },
      });
    </script>
    <script>
      // const iframe = document.getElementById('docIframe');
      // docIframe.src = window.frameSrc;
    </script>
  </body>
</html>
